import java.util.concurrent.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 19182
 * Date: 2025-09-02
 * Time: 21:23
 */
public class demo4 {
    public static void main(String[] args) {
        int corePoolSize = 10;
        int maximumPoolSize = 15;
        long keepAlive = 5;
        BlockingQueue<Runnable> queue = new ArrayBlockingQueue<>(10);
        ThreadFactory threadFactory = Executors.defaultThreadFactory();
        RejectedExecutionHandler hanlder = new ThreadPoolExecutor.AbortPolicy();
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
                corePoolSize,
                maximumPoolSize,
                keepAlive,
                TimeUnit.SECONDS,
                queue,
                threadFactory,
                hanlder
        );
        for(int i = 0; i < 100; i++){
            threadPoolExecutor.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName() + "线程执行");
                }
            });
        }

    }
}
